import string

from util.DB import get_conn


def select_Info(table_schema: string) -> list:
    sql: string = "SELECT table_schema AS '数据库',TABLE_NAME AS '表名',table_rows AS '记录数', TRUNCATE(" \
                  "data_length/1024/1024, 2) AS '数据容量(MB)',TRUNCATE(data_free/1024/1024, 2) AS '数据空洞(MB)'," \
                  "TRUNCATE(index_length/1024/1024, 2) AS '索引容量(MB)' FROM information_schema.tables where " \
                  "table_schema = %s ORDER BY data_length DESC, index_length DESC "
    # 连接数据库
    conn = get_conn()
    # 使用 cursor() 方法创建一个游标对象 cursor
    params = table_schema
    cursor = conn.cursor()
    cursor.execute(sql, params)
    data = cursor.fetchall()
    return data
